<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>分班</title>
    <link rel="stylesheet" href="layui-v2.5.6\layui\css\layui.css"  media="all">
    <script src="layui-v2.5.6\layui\layui.js" charset="utf-8"></script>
    <script src="vue\axios.js"></script>
    <script src="vue\Vue.js"></script>
</head>
<body>
    <div id="app">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>时间规划</legend>
        </fieldset>

        <div class="layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">开始时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="beginTime" placeholder="yyyy-MM-dd">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">结束时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="endTime" placeholder="yyyy-MM-dd">
                    </div>
                </div>
            </div>
        </div>


        <div style="width: 80%; margin: 30px auto">
            <button type="button" class="layui-btn layui-btn-fluid" @click="gainTime()">开始发布</button>
        </div>
    </div>
</body>
<script>
    var beginTime,endTime;

    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //起始时间
        laydate.render({
            elem: '#beginTime'
            ,type: 'datetime'
            ,done: function(value,date,endDate){
                beginTime = value;
            }
        });
        //最后时间
        laydate.render({
            elem: '#endTime'
            ,type: 'datetime'
            ,done: function(value,date,endDate){
                endTime = value;
            }
        });
    });
    new Vue({
        el: "#app"
        ,data:{}
        ,methods:{
            gainTime:function(){
                if (beginTime == undefined)
                    beginTime = null;
                if (endTime == undefined)
                    endTime = null;
                let params = new URLSearchParams();
                params.append("beginTime",beginTime);
                params.append("endTime",endTime);
                axios
                    .post("special/divideClass",params)
                    .then(res=>{
                        alert(res)
                    });
            }
        }
    });
</script>
</html>